package com.kefu.chat.vo;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.kefu.chat.model.ChatMenuConfig;
import com.kefu.common.context.KefuContext;
import com.kefu.common.vo.AbstractSearchVo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
public class ChatMenuConfigSearchVo extends AbstractSearchVo {

    @ApiModelProperty(value = "菜单名称")
    private String menuName;

    @Override
    public LambdaQueryWrapper lambdaQuery() {
        LambdaQueryWrapper<ChatMenuConfig> wrapper = Wrappers.lambdaQuery(ChatMenuConfig.class);
        if (StrUtil.isNotBlank(menuName)) {
            wrapper.like(ChatMenuConfig::getMenuName, menuName);
        }
        wrapper.eq(ChatMenuConfig::getTenantId, KefuContext.getKefuContext().getTenantId());
        wrapper.orderByDesc(ChatMenuConfig::getCreateTime);
        return wrapper;
    }
}
